import 'package:winkai/generated/json/base/json_convert_content.dart';
import 'package:winkai/helper/iap/entity/g_iap_rsp.dart';

GIAPRsp $GIAPRspFromJson(Map<String, dynamic> json) {
  final GIAPRsp gIAPRsp = GIAPRsp();
  final GIAPRspEntity? entity = jsonConvert.convert<GIAPRspEntity>(
      json['entity']);
  if (entity != null) {
    gIAPRsp.entity = entity;
  }
  final List<dynamic>? checks = (json['checks'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (checks != null) {
    gIAPRsp.checks = checks;
  }
  return gIAPRsp;
}

Map<String, dynamic> $GIAPRspToJson(GIAPRsp entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['entity'] = entity.entity?.toJson();
  data['checks'] = entity.checks;
  return data;
}

extension GIAPRspExtension on GIAPRsp {
  GIAPRsp copyWith({
    GIAPRspEntity? entity,
    List<dynamic>? checks,
  }) {
    return GIAPRsp()
      ..entity = entity ?? this.entity
      ..checks = checks ?? this.checks;
  }
}

GIAPRspEntity $GIAPRspEntityFromJson(Map<String, dynamic> json) {
  final GIAPRspEntity gIAPRspEntity = GIAPRspEntity();
  final String? environment = jsonConvert.convert<String>(json['environment']);
  if (environment != null) {
    gIAPRspEntity.environment = environment;
  }
  final bool? ok = jsonConvert.convert<bool>(json['ok']);
  if (ok != null) {
    gIAPRspEntity.ok = ok;
  }
  final String? deviceId = jsonConvert.convert<String>(json['device_id']);
  if (deviceId != null) {
    gIAPRspEntity.deviceId = deviceId;
  }
  final int? expiresDateMs = jsonConvert.convert<int>(json['expires_date_ms']);
  if (expiresDateMs != null) {
    gIAPRspEntity.expiresDateMs = expiresDateMs;
  }
  return gIAPRspEntity;
}

Map<String, dynamic> $GIAPRspEntityToJson(GIAPRspEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['environment'] = entity.environment;
  data['ok'] = entity.ok;
  data['device_id'] = entity.deviceId;
  data['expires_date_ms'] = entity.expiresDateMs;
  return data;
}

extension GIAPRspEntityExtension on GIAPRspEntity {
  GIAPRspEntity copyWith({
    String? environment,
    bool? ok,
    String? deviceId,
    int? expiresDateMs,
  }) {
    return GIAPRspEntity()
      ..environment = environment ?? this.environment
      ..ok = ok ?? this.ok
      ..deviceId = deviceId ?? this.deviceId
      ..expiresDateMs = expiresDateMs ?? this.expiresDateMs;
  }
}